/* 导入字体 */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* 全局样式 */
:root {
    --primary-color: #4e54c8;
    --primary-light: #8f94fb;
    --secondary-color: #ff8c00;
    --text-color: #333;
    --light-text: #777;
    --background: #f8f9fa;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeIn 0.8s ease-out;
}

header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

header p {
    color: var(--light-text);
    font-size: 1.1rem;
}

/* 主要内容区域 */
main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* 颜色输入区域 */
.color-input {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    animation: slideInLeft 0.8s ease-out;
}

.main-color-section,
.palette-section,
.custom-colors-section {
    margin-bottom: 2rem;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-picker-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

input[type="color"] {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px #ddd;
}

input[type="text"] {
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    width: 120px;
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(78, 84, 200, 0.1);
}

.color-preview {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    transition: var(--transition);
}

.custom-preview {
    height: 60px;
}

/* 方案选择按钮 */
.scheme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.scheme-btn {
    padding: 0.6rem 1rem;
    background-color: #f0f2f5;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    color: var(--text-color);
}

.scheme-btn:hover {
    background-color: #e4e6eb;
}

.scheme-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* 自定义颜色区域 */
.custom-color-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: 8px;
    animation: fadeIn 0.5s ease-out;
}

.add-btn {
    background-color: var(--primary-light);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    margin-left: 0.5rem;
}

.add-btn:hover {
    background-color: var(--primary-color);
    transform: scale(1.1);
}

.remove-btn {
    background-color: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.remove-btn:hover {
    background-color: #ff5252;
    transform: scale(1.1);
}

/* 生成按钮 */
.generate-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.generate-btn:hover {
    background-color: #3f44ae;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

/* 结果区域 */
.results-section {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    animation: slideInRight 0.8s ease-out;
    display: flex;
    flex-direction: column;
    opacity: 0.7;
    transition: var(--transition);
}

.results-section.active {
    opacity: 1;
}

.palette-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.color-card {
    flex: 1;
    min-width: 100px;
    height: 120px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    animation: scaleIn 0.5s ease-out;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.color-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.color-card::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
    z-index: 1;
}

.color-card span {
    position: relative;
    z-index: 2;
}

/* 和谐度评分 */
.palette-info {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.harmony-score {
    background-color: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.score-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.score-bar-container {
    width: 100%;
    height: 10px;
    background-color: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.score-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(to right, #ff8c00, #ff5252);
    border-radius: 5px;
    transition: width 1.5s cubic-bezier(0.19, 1, 0.22, 1);
}

/* 配色详情 */
.palette-details {
    background-color: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
}

.color-detail {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.5s ease-out;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.color-info {
    flex-grow: 1;
}

.color-name {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.color-hex {
    color: var(--light-text);
    font-size: 0.9rem;
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    gap: 1rem;
}

.action-btn {
    flex: 1;
    padding: 0.8rem 1rem;
    background-color: #f0f2f5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background-color: #e4e6eb;
}

#saveBtn {
    background-color: var(--primary-light);
    color: white;
}

#saveBtn:hover {
    background-color: var(--primary-color);
}

#copyBtn {
    background-color: var(--secondary-color);
    color: white;
}

#copyBtn:hover {
    background-color: #e67e00;
}

/* 已保存的配色 */
.saved-palettes {
    margin-bottom: 3rem;
    animation: fadeIn 1s ease-out;
}

.saved-palettes h2 {
    margin-bottom: 1.5rem;
}

.saved-palettes-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
}

.saved-palette {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    animation: fadeIn 0.5s ease-out;
}

.saved-palette:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.saved-colors {
    display: flex;
    height: 100px;
}

.saved-color {
    flex: 1;
}

.saved-palette-info {
    padding: 1.5rem;
}

.saved-palette-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.saved-palette-date {
    color: var(--light-text);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.saved-palette-actions {
    display: flex;
    gap: 0.5rem;
}

.saved-palette-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.load-btn {
    background-color: var(--primary-light);
    color: white;
}

.load-btn:hover {
    background-color: var(--primary-color);
}

.delete-btn {
    background-color: #ff6b6b;
    color: white;
}

.delete-btn:hover {
    background-color: #ff5252;
}

/* 页脚 */
footer {
    text-align: center;
    color: var(--light-text);
    padding: 2rem 0;
    border-top: 1px solid #eee;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* 响应式设计 */
@media (max-width: 992px) {
    main {
        grid-template-columns: 1fr;
    }

    .palette-info {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        margin-bottom: 2rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .scheme-options {
        flex-direction: column;
    }

    .scheme-btn {
        width: 100%;
    }

    .saved-palettes-container {
        grid-template-columns: 1fr;
    }
}

/* 工具提示 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8rem;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 复制成功提示 */
.copy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.copy-toast.show {
    opacity: 1;
}